home *** CD-ROM | disk | FTP | other *** search
- /* */
- /****************************************************************
- * *
- * typedefs of the complete DDLC register structure *
- * *
- * (DDLC = MC145488 - Dual Data Link Controller) *
- * (These structures are from booklet ADI1524 aka MC145488/D) *
- * *
- * A device driver for KA9Q NOS (92)0521 or later version. *
- * By Matti Aarnio <mea@utu.fi> OH1MQK *
- * *
- ****************************************************************/
-
- #ifndef DDLCMAX
- #define DDLCMAX 2 /* 2 boards, 4 channels each */
- #define CHANNELS_ON_BOARD 4
- #define LOG_CHANNELS_ON_BOARD 2
- #define DDLCCMAX (DDLCMAX*CHANNELS_ON_BOARD)
- #include "global.h"
- #define AX_MTU 512
-
-
- #define OFF 0
- #define ON 1
-
- #if DDLCMAX == 2
- /* In ddlcvec.asm: */
- INTERRUPT ddlc0vec __ARGS((void));
- INTERRUPT ddlc1vec __ARGS((void));
- #endif
-
- /* In ddlc.c: */
- /*INTERRUPT (far *(ddlcint) __ARGS((int dev)))();*/
-
- /*#define INTEGER short int*/
- #define BIT_FIELD unsigned
-
- /*
- * Individual register unions - both for little-endian, as well as
- * big endian..
- */
- typedef union { /* System control register */
- int16 SysCntr;
- struct {
- #ifdef _BIG_ENDIAN /* 68000 et.al. */
- BIT_FIELD : 8; /* 8-f: Dummy bits */
- BIT_FIELD TEST : 3; /* 5-7: Factory Test Modes */
- BIT_FIELD DTACKEn : 1; /* 4: DTACK Enable */
- BIT_FIELD WAIT : 2; /* 2-3: Wait State Select */
- BIT_FIELD RESET : 1; /* 1: Software Reset */
- BIT_FIELD BW : 1; /* 0: Bus Width (status) */
- #else /* Little-endian */
- BIT_FIELD BW : 1; /* 0: Bus Width (status) */
- BIT_FIELD RESET : 1; /* 1: Software Reset */
- BIT_FIELD WAIT : 2; /* 2-3: Wait State Select */
- BIT_FIELD DTACKEn : 1; /* 4: DTACK Enable */
- BIT_FIELD TEST : 3; /* 5-7: Factory Test Modes */
- BIT_FIELD : 8; /* 8-f: Dummy bits */
- #endif
- } sys_control;
- } SYSCONTROL;
-
- typedef union { /* master status register (vector) */
- int16 Vector;
- struct {
- #ifdef _BIG_ENDIAN
- BIT_FIELD : 8; /* 8-f: Dummy Bits */
- BIT_FIELD VecUser : 4; /* 4-7: User programmable bits */
- BIT_FIELD VecNum : 4; /* 0-3: Vector number */
- #else /* Little-endian */
- BIT_FIELD VecNum : 4; /* 0-3: Vector number */
- BIT_FIELD VecUser : 4; /* 4-7: User programmable bits */
- BIT_FIELD : 8; /* 8-f: Dummy Bits */
- #endif
- } mstr_stat;
- } MASTERSTATUS;
-
- typedef union { /* Interrupt enable register */
- int16 IntEn;
- struct {
- #ifdef _BIG_ENDIAN
- BIT_FIELD SCPC : 1; /* f: SCP Interrupt Enable */
- BIT_FIELD CD1 : 1; /* e: CD1 Interrupt Enable */
- BIT_FIELD CD0 : 1; /* d: CD0 Interrupt Enable */
- BIT_FIELD Rx1Idl : 1; /* c: Ch 1 Idle Interrupt Enable */
- BIT_FIELD Rx0Idl : 1; /* b: Ch 0 Idle Interrupt Enable */
- BIT_FIELD RxBOvr : 1; /* a: Rx Buffer Overrun Int Enable */
- BIT_FIELD TxFUnr : 1; /* 9: Tx FIFO Underrun Int Enable */
- BIT_FIELD RxFOvr : 1; /* 8: Rx FIFO Overrun Int Enable */
- BIT_FIELD Tx1FC : 1; /* 7: Ch 1 Tx Frame Complete Int Ena */
- BIT_FIELD Tx0FC : 1; /* 6: Ch 0 Tx Frame Complete Int Ena */
- BIT_FIELD Tx1DMAC : 1; /* 5: Ch 1 Tx DMA Complete Int Ena */
- BIT_FIELD Tx0DMAC : 1; /* 4: Ch 0 Tx DMA Complete Int Ena */
- BIT_FIELD Rx1DMAC : 1; /* 3: Ch 1 Rx DMA Complete Int Ena */
- BIT_FIELD Rx0DMAC : 1; /* 2: Ch 0 Rx DMA Complete Int Ena */
- BIT_FIELD AddrErr : 1; /* 1: Address Error Interrupt Ena */
- BIT_FIELD BusErr : 1; /* 0: Bus Error Interrupt Enable */
- #else /* Little-endian */
- BIT_FIELD BusErr : 1; /* 0: Bus Error Interrupt Enable */
- BIT_FIELD AddrErr : 1; /* 1: Address Error Interrupt Ena */
- BIT_FIELD Rx0DMAC : 1; /* 2: Ch 0 Rx DMA Complete Int Ena */
- BIT_FIELD Rx1DMAC : 1; /* 3: Ch 1 Rx DMA Complete Int Ena */
- BIT_FIELD Tx0DMAC : 1; /* 4: Ch 0 Tx DMA Complete Int Ena */
- BIT_FIELD Tx1DMAC : 1; /* 5: Ch 1 Tx DMA Complete Int Ena */
- BIT_FIELD Tx0FC : 1; /* 6: Ch 0 Tx Frame Complete Int Ena */
- BIT_FIELD Tx1FC : 1; /* 7: Ch 1 Tx Frame Complete Int Ena */
- BIT_FIELD RxFOvr : 1; /* 8: Rx FIFO Overrun Int Enable */
- BIT_FIELD TxFUnr : 1; /* 9: Tx FIFO Underrun Int Enable */
- BIT_FIELD RxBOvr : 1; /* a: Rx Buffer Overrun Int Enable */
- BIT_FIELD Rx0Idl : 1; /* b: Ch 0 Idle Interrupt Enable */
- BIT_FIELD Rx1Idl : 1; /* c: Ch 1 Idle Interrupt Enable */
- BIT_FIELD CD0 : 1; /* d: CD0 Interrupt Enable */
- BIT_FIELD CD1 : 1; /* e: CD1 Interrupt Enable */
- BIT_FIELD SCPC : 1; /* f: SCP Interrupt Enable */
- #endif
- } int_enable;
- } IRQE;
-
- typedef union { /* SCP status/control register */
- int16 SCPReg;
- struct {
- #ifdef _BIG_ENDIAN
- BIT_FIELD : 1; /* f: SCP Complete */
- BIT_FIELD : 1; /* e: Slave/master select */
- BIT_FIELD CI : 1; /* d: SCP Clock Invert */
- BIT_FIELD BR : 2; /* b-c: SCP Baud Rate Select */
- BIT_FIELD En1 : 1; /* a: SCP Enable 1 */
- BIT_FIELD En0 : 1; /* 9: SCP Enable 0 */
- BIT_FIELD TxEn : 1; /* 8: SCP Transmit Enable */
- BIT_FIELD TxRx : 8; /* 0-7: SCP Tx/Rx Register */
- #else /* Little-endian */
- BIT_FIELD TxEn : 1; /* 8: SCP Transmit Enable */
- BIT_FIELD En0 : 1; /* 9: SCP Enable 0 */
- BIT_FIELD En1 : 1; /* a: SCP Enable 1 */
- BIT_FIELD BR : 2; /* b-c: SCP Baud Rate Select */
- BIT_FIELD CI : 1; /* d: SCP Clock Invert */
- BIT_FIELD : 1; /* e: Slave/master select */
- BIT_FIELD : 1; /* f: SCP Complete */
- #endif
- } scpreg;
- } SCP;
-
- typedef union { /* Timer register */
- int16 timer;
- struct {
- #ifdef _BIG_ENDIAN
- BIT_FIELD : 5; /* b-f: Dummy bits */
- BIT_FIELD TIRQ : 1; /* a: Timer Interrupt Status bit */
- BIT_FIELD WDE : 1; /* 9: Watchdog Enable (chan 0 only) */
- BIT_FIELD TEN : 1; /* 8: Timer Enable */
- BIT_FIELD count : 8; /* 0-7: 8-bit Timer Register */
- #else /* Little-endian */
- BIT_FIELD count : 8; /* 0-7: 8-bit Timer Register */
- BIT_FIELD TEN : 1; /* 8: Timer Enable */
- BIT_FIELD WDE : 1; /* 9: Watchdog Enable (chan 0 only) */
- BIT_FIELD TIRQ : 1; /* a: Timer Interrupt Status bit */
- BIT_FIELD : 5; /* b-f: Dummy bits */
- #endif
- } Timer;
- } TIMER;
-
-
- /*
- * Structure of the channel's status/control and buffer
- * descriptor registers
- */
- typedef struct { /* Channel status/control registers */
- union {
- int16 SerCont;
- struct {
- #ifdef _BIG_ENDIAN
- BIT_FIELD : 1; /* f: Dummy bit */
- BIT_FIELD SCPE : 1; /* e: SCP Enable */
- BIT_FIELD TOL : 1; /* d: Transmit on Loop */
- BIT_FIELD LOOP : 1; /* c: Loopback */
- BIT_FIELD TRSP : 1; /* b: Transparent Operation */
- BIT_FIELD MODE : 3; /* 8-a: Mode Bits */
- BIT_FIELD MASK : 8; /* 0-7: Bit Mask Register */
- #else /* Little-endian */
- BIT_FIELD MASK : 8; /* 0-7: Bit Mask Register */
- BIT_FIELD MODE : 3; /* 8-a: Mode Bits */
- BIT_FIELD TRSP : 1; /* b: Transparent Operation */
- BIT_FIELD LOOP : 1; /* c: Loopback */
- BIT_FIELD TOL : 1; /* d: Transmit on Loop */
- BIT_FIELD SCPE : 1; /* e: SCP Enable */
- BIT_FIELD : 1; /* f: Dummy bit */
- #endif
- } serial_control;
- } SerControl;
- union { /* transmit control register */
- int16 TxCntr;
- struct {
- #ifdef _BIG_ENDIAN
- BIT_FIELD : 9; /* 7-f: Dummy bits */
- BIT_FIELD DI : 1; /* 6: Data Invert */
- BIT_FIELD FA : 1; /* 5: Force Abort */
- BIT_FIELD MD : 1; /* 4: Mask Drive */
- BIT_FIELD FCE : 1; /* 3: Force CRC Error */
- BIT_FIELD ITF : 1; /* 2: Inter-frame Time Fill */
- BIT_FIELD BR : 1; /* 1: Buffer Ready */
- BIT_FIELD TE : 1; /* 0: Transmit Enable */
- #else /* Little-endian */
- BIT_FIELD TE : 1; /* 0: Transmit Enable */
- BIT_FIELD BR : 1; /* 1: Buffer Ready */
- BIT_FIELD ITF : 1; /* 2: Inter-frame Time Fill */
- BIT_FIELD FCE : 1; /* 3: Force CRC Error */
- BIT_FIELD MD : 1; /* 4: Mask Drive */
- BIT_FIELD FA : 1; /* 5: Force Abort */
- BIT_FIELD DI : 1; /* 6: Data Invert */
- BIT_FIELD : 9; /* 7-f: Dummy bits */
- #endif
- } tx_control;
- } TxCont;
- union { /* receive control register */
- int16 RxCntr;
- struct {
- #ifdef _BIG_ENDIAN
- BIT_FIELD : 9; /* 7-f: Dummy Bits */
- BIT_FIELD DI : 1; /* 6: Data Invert */
- BIT_FIELD ABS : 1; /* 5: Address Byte Select */
- BIT_FIELD ACE : 1; /* 4: Address Compare Enable */
- BIT_FIELD RCE : 1; /* 3: Receive on CRC Error */
- BIT_FIELD BBR : 1; /* 2: Buffer B Ready */
- BIT_FIELD BAR : 1; /* 1: Buffer A Ready */
- BIT_FIELD RE : 1; /* 0: Receiver Enable */
- #else /* Little-endian */
- BIT_FIELD RE : 1; /* 0: Receiver Enable */
- BIT_FIELD BAR : 1; /* 1: Buffer A Ready */
- BIT_FIELD BBR : 1; /* 2: Buffer B Ready */
- BIT_FIELD RCE : 1; /* 3: Receive on CRC Error */
- BIT_FIELD ACE : 1; /* 4: Address Compare Enable */
- BIT_FIELD ABS : 1; /* 5: Address Byte Select */
- BIT_FIELD DI : 1; /* 6: Data Invert */
- BIT_FIELD : 9; /* 7-f: Dummy Bits */
- #endif
- } rx_control;
- } RxCont;
- union { /* transmit status register */
- int16 TxStatus;
- struct {
- #ifdef _BIG_ENDIAN
- BIT_FIELD :10; /* 6-f: Dummy Bits */
- BIT_FIELD FUN : 1; /* 5: FIFO Underrun */
- BIT_FIELD TFC : 1; /* 4: Transmit Frame Complete */
- BIT_FIELD CTS : 1; /* 3: CTS status */
- BIT_FIELD BE : 1; /* 2: Bus Error */
- BIT_FIELD AE : 1; /* 1: Address Error */
- BIT_FIELD TDC : 1; /* 0: Transmit DMA Complete */
- #else /* Little-endian */
- BIT_FIELD TDC : 1; /* 0: Transmit DMA Complete */
- BIT_FIELD AE : 1; /* 1: Address Error */
- BIT_FIELD BE : 1; /* 2: Bus Error */
- BIT_FIELD CTS : 1; /* 3: CTS status */
- BIT_FIELD TFC : 1; /* 4: Transmit Frame Complete */
- BIT_FIELD FUN : 1; /* 5: FIFO Underrun */
- BIT_FIELD :10; /* 6-f: Dummy Bits */
- #endif
- } tx_stat;
- } TxStat;
- union { /* receive status register */
- int16 RxStatus;
- struct {
- #ifdef _BIG_ENDIAN
- BIT_FIELD CD : 1; /* f: CD pin status */
- BIT_FIELD RI : 1; /* e: receiver Link Idle */
- BIT_FIELD CE : 1; /* d: CRC Error */
- BIT_FIELD CDIRQ : 1; /* c: CD Interrupt Status */
- BIT_FIELD FO : 1; /* b: FIFO Overrun */
- BIT_FIELD RC : 3; /* 8-a: Residue Count */
- BIT_FIELD : 2; /* 6-7: Dummy Bits */
- BIT_FIELD BE : 1; /* 5: Bus Error */
- BIT_FIELD AE : 1; /* 4: Address Error */
- BIT_FIELD BBO : 1; /* 3: Buffer B Overrun */
- BIT_FIELD BAO : 1; /* 2: Buffer A Overrun */
- BIT_FIELD RBC : 1; /* 1: Buffer B Complete */
- BIT_FIELD RAC : 1; /* 0: Buffer A Complete */
- #else /* Little-endian */
- BIT_FIELD RAC : 1; /* 0: Buffer A Complete */
- BIT_FIELD RBC : 1; /* 1: Buffer B Complete */
- BIT_FIELD BAO : 1; /* 2: Buffer A Overrun */
- BIT_FIELD BBO : 1; /* 3: Buffer B Overrun */
- BIT_FIELD AE : 1; /* 4: Address Error */
- BIT_FIELD BE : 1; /* 5: Bus Error */
- BIT_FIELD : 2; /* 6-7: Dummy Bits */
- BIT_FIELD RC : 3; /* 8-a: Residue Count */
- BIT_FIELD FO : 1; /* b: FIFO Overrun */
- BIT_FIELD CDIRQ : 1; /* c: CD Interrupt Status */
- BIT_FIELD CE : 1; /* d: CRC Error */
- BIT_FIELD RI : 1; /* e: receiver Link Idle */
- BIT_FIELD CD : 1; /* f: CD pin status */
- #endif
- } rx_status;
- } RxStat;
- struct { /* address compare register */
- #ifdef _BIG_ENDIAN
- unsigned char AddrComp1; /* 8-f: Compare Address 1 */
- unsigned char AddrComp0; /* 0-7: Compare Address 0 */
- #else /* Little-endian */
- unsigned char AddrComp0; /* 0-7: Compare Address 0 */
- unsigned char AddrComp1; /* 8-f: Compare Address 1 */
- #endif
- } AddCmp;
- union { /* wildcard register */
- int16 Wild;
- struct {
- #ifdef _BIG_ENDIAN
- BIT_FIELD : 8; /* 8-f: Dummy Bits */
- BIT_FIELD WildCard: 8; /* 0-7: Address Wildcard Bits */
- #else /* Little-endian */
- BIT_FIELD WildCard: 8; /* 0-7: Address Wildcard Bits */
- BIT_FIELD : 8; /* 8-f: Dummy Bits */
- #endif
- } wildbits;
- } WildBits;
- union { /* CRC error count */
- int16 CRCErr;
- struct {
- #ifdef _BIG_ENDIAN
- BIT_FIELD : 8; /* 8-f: Dummy Bits */
- BIT_FIELD CRCError: 8; /* 0-7: CRC Error Count */
- #else /* Little-endian */
- BIT_FIELD CRCError: 8; /* 0-7: CRC Error Count */
- BIT_FIELD : 8; /* 8-f: Dummy Bits */
- #endif
- } crcerrors;
- } CRCErrors;
- int16 TxFrLen; /* Transmit Frame Length */
- int16 TxBase; /* Transmit Buffer Base Address */
- int16 TxByteCnt; /* Transmit Byte Count */
- int16 RxBufLen; /* Receive Buffer Length */
- int16 RxABase; /* Receive Buffer A Base Address */
- int16 RxAByteCnt; /* Receive Buffer A Byte Count */
- int16 RxBBase; /* Receive Buffer B Base Address */
- int16 RxBByteCnt; /* Receive Buffer B Byte Count */
- } CH_REGS;
-
- /*
- * typedef of the complete DDLC register structure
- */
- typedef struct {
- SYSCONTROL System; /* System control register */
- MASTERSTATUS MStat; /* Master status register */
- IRQE Interrupt; /* Interrupt enable register */
- int16 Select16; /* Dummy register for 16-bit bus */
- int16 unused_space0[4]; /* unused space */
- SCP scp; /* SCP register */
- TIMER timeout[2]; /* Timer registers */
- int16 unused_space1[5]; /* unused space */
- CH_REGS Ch_Regs[2]; /* Channel status/control registers */
- int16 _dummy_space[16]; /* Not used */
- } DDLC;
-
- #ifndef NO_NOS_PARTS
- /* Now real NOS device driver parts.. */
-
- struct DDLCTAB {
- INTERRUPT (*oldvec) __ARGS((void)); /* Original interrupt vector contents */
- char far* boardbase; /* DDLC card base address */
- int16 boardsize; /* 2-port memory size: 16k/32k */
- unsigned vec; /* Interrupt vector of this board */
- long ints; /* Interrupt count */
- char channelcnt; /* 2 or 4 channels equiped */
- char far* nextfreebuf; /* for allocating buffers for channels */
- int bufavail; /* For monitoring the allocation of buffer */
- int attachlog; /* |= 1 << (channel & 3) */
- int16 dtrreg; /* Write-only register.. */
- };
-
- extern struct DDLCTAB Ddlc[];
-
-
- struct ddlcchan {
- long rxints; /* Receiver interrupts */
- long txints; /* Transmitter interrupts */
- long exints; /* External/status interrupts */
-
- long enqueued; /* Packets enqueued for transmit */
- long rxframes; /* Packets received */
- int crcerrs; /* CRC Errors */
- int rovers; /* Receiver overruns */
- int tunders; /* Transmitter underruns */
-
- /*?*/ struct mbuf *rcvbuf; /* Buffer for current rx packet */
- int16 bufsiz; /* Size of rcv- and txbufs (rcpX, txpX) */
- char *rcp1, *rcp2; /* Pointer into rcvbuf */
- char rxside; /* ==0: Pick rcp1 first, else pick rcp2 */
-
- struct mbuf *sndq; /* Packets awaiting transmission */
- int16 sndcnt; /* Number of packet on sndq */
- struct mbuf *sndbuf; /* Current buffer being transmitted */
- char *txp1, *txp2; /* Pointer into transmit buffer */
- int16 TxAbase; /* Value to be loaded into DDLC channel */
- int16 TxBbase; /* TxBase -register for txp1/txp2.. */
- char txside; /* 0: use TxAbase, !0: use TxBbase */
- char tstate; /* Transmitter state */
- #define IDLE 0 /* Transmitter off, no data pending */
- #define ACTIVE 1 /* Transmitter on, sending data */
- #define UNDERRUN 2 /* Transmitter on, flushing CRC */
- #define FLAGOUT 3 /* CRC sent - attempt to start next frame*/
- #define DEFER 4 /* Receive Active - DEFER Transmit */
- #define ST_TXDELAY 5 /* Sending leading flags */
- #define CRCOUT 6
- struct timer defer; /* Delay timer */
- char rstate; /* Set when !DCD goes to 0 (TRUE) */
- /* Normal state is ACTIVE if Receive enabled */
- #define RXERROR 2 /* Error -- Aborting current Frame */
- #define RXABORT 3 /* ABORT sequence detected */
- #define TOOBIG 4 /* too large a frame to store */
- struct DDLCTAB *Board; /* Pointer to board data */
- int16 dev; /* Device number */
- int16 unit; /* channel nro on board: 0..3 */
- /* Shared memory handling ? */
- char *speed; /* Line speed, bps (informational only) */
- char duplex; /* 0 == half-duplex */
- int16 txdelay; /* Transmit Delay 10 ms/cnt */
- char persist; /* Persistence (0-255) as a % */
- int16 slotime; /* Delay to wait on persistence hit */
- int16 squeldelay; /* Delay after XMTR OFF for squelch tail */
- int16 waittime; /* XX: ?? from scc.c */
- int16 maxkeyup; /* XX: ?? from scc.c */
- int16 mintime; /* XX: ?? from scc.c */
- int16 idletime; /* XX: ?? from scc.c */
- int16 group; /* XX: ?? from scc.c */
- int16 enddelay; /* XX: ?? from scc.c */
- struct iface *iface; /* Associated interface */
- int32 deftime; /* Time when xmit is enabled */
- };
-
- #endif /* ifndef NO_NOS_PARTS */
- #endif /* ifndef DDLCMAX */
-